home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1585 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c,comp.os.msdos.programmer
  4. Subject: Re: tc++: vram 4 K segment warp-around ?
  5. Followup-To: comp.os.msdos.programmer
  6. Date: 15 Jan 1996 15:37:04 GMT
  7. Organization: Internet Access Group, Orlando, Florida
  8. Message-ID: <4ddsb0$1a1@news.iag.net>
  9. References: <30F6DE8A.20CD@ivic.qc.ca>
  10. NNTP-Posting-Host: pm1-orl26.iag.net
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13. In article <30F6DE8A.20CD@ivic.qc.ca>, jblanc@ivic.qc.ca says...
  14. >
  15. >/*
  16. >   * help me!  i'm using tc++ 3.0, and the following code outputs:
  17. >   *  p1 -> 3, p2 -> 3, p3 -> 3
  18. >   * can someone explain me this 4 K warp-around?
  19. >   *
  20. >   * [ in fact, what i really intend is to use vram as a 1 K aligned
  21. >   * buffer. if you have any other idea about how to achieve that (more
  22. >   * portably, i hope), tell me! ]
  23. >   */
  24. >
  25. >#include <dos.h>
  26. >
  27. >int main()
  28. >{
  29. >/* ptrs to video mem */
  30. >  int far *p1 = (int far *) MK_FP(0xA000, 0x0000);
  31. >  int far *p2 = (int far *) MK_FP(0xA000, 0x1000);
  32. >  int far *p3 = (int far *) MK_FP(0xB000, 0x1000);
  33. >
  34. >  *p1 = 1;
  35. >  *p2 = 2;
  36. >  *p3 = 3;
  37. >
  38. >  printf("p1 -> %x, p2 -> %x, p3 -> %x\n", *p1, *p2, *p3);
  39. >  return 0;
  40. >}
  41.  
  42. Hmm... Maybe one of the bugs in TC 3.0?  Using BC 3.1, I got the expected 
  43. output. To verfiy the pointers I tried it again, adding the following printf
  44. (I had to switch to large memory model to get printf to print segment/offet
  45. notation)
  46.  
  47.   printf("%p\t%p\t%p\n", (void *)p1, (void *)p2, (void *)p3);
  48.  
  49. The output, as expected, was:
  50.  
  51. A000:0000       A000:1000       B000:1000
  52. p1 -> 1, p2 -> 2, p3 -> 3
  53.  
  54. You might want to try this to verify that MK_FP is functioning properly
  55. in your version.  You might also try verifying each assignment immediately
  56. after it's made. Beyond that you might poke aroung www.borland.com and see
  57. if they have any info on it.
  58.  
  59. This is a compiler/system specific problem.  So I an redirecting follow-ups
  60. to comp.os.msdos.programmer.  You are much more likely to find people
  61. there, who are intimately familiar with DOS and TC 3.0.
  62.  
  63. -- 
  64. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  65. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  66.  
  67.